<?php

/**
 * This is the model class for table "tugasakhir".
 *
 * The followings are the available columns in table 'tugasakhir':
 * @property integer $ID_TA
 * @property string $Title
 * @property string $Tahun
 * @property string $Abstrak
 * @property string $TAPath
 * @property string $PaperPath
 * @property string $PosterPath
 * @property integer $downloaded
 * @property string $uploadtime
 *
 * The followings are the available model relations:
 * @property Membimbing[] $membimbings
 * @property Tag[] $tags
 */
class TugasAkhir extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return TugasAkhir the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tugasakhir';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('Title, Tahun, Abstrak, TAPath, PaperPath, PosterPath, downloaded, uploadtime', 'required'),
			array('downloaded', 'numerical', 'integerOnly'=>true),
			array('Title', 'length', 'max'=>50),
			array('Tahun', 'length', 'max'=>4),
			array('TAPath, PaperPath, PosterPath', 'length', 'max'=>100),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_TA, Title, Tahun, Abstrak, TAPath, PaperPath, PosterPath, downloaded, uploadtime', 'safe', 'on'=>'search'),
                        array('PosterPath','file','types'=>'jpg,gif,png','allowEmpty'=>true, 'on'=>'update'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'membimbings' => array(self::HAS_MANY, 'Membimbing', 'ID_TA'),
			'tags' => array(self::MANY_MANY, 'Tag', 'ta_tag(ID_TA, ID_Tag)'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_TA' => 'Id Ta',
			'Title' => 'Title',
			'Tahun' => 'Tahun',
			'Abstrak' => 'Abstrak',
			'TAPath' => 'Tapath',
			'PaperPath' => 'Paper Path',
			'PosterPath' => 'Poster Path',
			'downloaded' => 'Downloaded',
			'uploadtime' => 'Uploadtime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_TA',$this->ID_TA);
		$criteria->compare('Title',$this->Title,true);
		$criteria->compare('Tahun',$this->Tahun,true);
		$criteria->compare('Abstrak',$this->Abstrak,true);
		$criteria->compare('TAPath',$this->TAPath,true);
		$criteria->compare('PaperPath',$this->PaperPath,true);
		$criteria->compare('PosterPath',$this->PosterPath,true);
		$criteria->compare('downloaded',$this->downloaded);
		$criteria->compare('uploadtime',$this->uploadtime,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}